In a coding architecture of high-efficiency video coding (High-efficiency Video Coding, HEVC), intra prediction (Intra Prediction) may be performed on a chroma component and a luma component by using directional prediction (Directional Prediction) and direct current prediction (DC Prediction). The Directional Prediction refers to performing prediction by using surrounding reconstructed pixel values according to a certain direction, and the DC Prediction refers to performing prediction by using an average value of reconstructed pixel values around a current pixel. When Intra Prediction is performed on a luma value, 34 kinds of prediction modes (Prediction Mode) can be selected, including DC Prediction and 33 kinds of directional prediction. During a video coding and decoding process, not all of the foregoing 34 kinds of prediction modes may be used, and other newly-extended prediction modes may also exist. The number of kinds of prediction modes is not limited in embodiments of the present invention.
In one example, when Intra Prediction is performed on a chroma component, the number of chroma Prediction Modes may be 5. As shown in Table 1, the five example Prediction Modes are: 0 - - - Vertical Prediction, 1 - - - Horizontal Prediction, 2 - - - DC Prediction, 3 - - - Down-Right Prediction, and 4 - - - chroma component prediction mode Luma Angle (indication: using the same prediction direction as a luma component). After an encoding end performs code rate distortion optimization to select an optimal Prediction Mode, binarization and entropy coding need to be performed on information of the optimal Prediction Mode and the coded information is transmitted to a decoding end, so as to ensure that the decoding end performs decoding correctly.
TABLE 1Intra prediction mode of a chroma component in HEVCPrediction Mode predictionMode Number mode numbermodeMode 0Vertical PredictionMode 1Horizontal PredictionMode 2DC PredictionMode 3Down-right PredictionMode 4Luma Angle
At the encoding end, binarization of a Prediction Mode is implemented as follows: If Prediction Mode=0, a flag=0 is output; otherwise, a flag=1 is output; and then, unary code (Unary Code) coding (Prediction Mode−1) is performed by using binarization coding to obtain a coding result. In the embodiments of the present invention, the binarization coding refers to a binarization coding manner in which the number of coding bits increases as a numeral of an input Mode increases, which is not described again in other parts of the embodiments of the present invention.
The foregoing Unary Code is a coding method for an integer belonging to [0, s]. When an input x satisfies 0<=x<s, an output result of the Unary Code is x 1s and one 0, and if s is input, an output result is s 1s.
At the decoding end, after a binary sequence is obtained through decoding, a Prediction Mode of the chroma component may be obtained through the following method: If a binary sequence bit is 0, a Prediction Mode number is 0; otherwise, decoding is performed according to a Unary Code principle; and if L is obtained through decoding, the Prediction Mode number is L+1.
It can be known from the foregoing binarization solution and the coding principle of the Unary Code that: When a value corresponding to the Prediction Mode is larger, more coding bits are needed. The Prediction Mode of the chroma component tends to be consistent with a Prediction Mode of a luma component. For example, when the Prediction Mode of the luma component is Modes 0˜3, Luma Angle may replace Modes 0˜3; and when the Prediction Mode of the luma component is not any one of Modes 0˜3, the Luma Angle cannot replace Modes 0˜3, and in this case, a probability that the prediction mode of the chroma component is the Luma Angle is generally high. Because lots of bits are needed to code the Luma Angle and the probability that the prediction mode of the chroma component is the Luma Angle is high, the efficiency of a coding manner of the foregoing binarization solution is low.